home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / pmlsrc / csubt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  3.5 KB  |  169 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    csubt   double precision complex subtraction
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    csubt
  29.  *    machine independent routines
  30.  *    complex functions
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex result of subtraction of
  36.  *    second double precision complex argument from first double
  37.  *    precision complex argument.
  38.  *
  39.  *    Note that the complex subtraction function is so simple that
  40.  *    it would not normally be called as a function but simply
  41.  *    done "inline".  It is supplied mostly for completeness.
  42.  *
  43.  *  USAGE
  44.  *
  45.  *    COMPLEX csubt (z1, z2)
  46.  *    COMPLEX z1;
  47.  *    COMPLEX z2;
  48.  *
  49.  *  PROGRAMMER
  50.  *
  51.  *    Fred Fish
  52.  *    Tempe, Az
  53.  *    (602) 966-8871
  54.  *
  55.  *  INTERNALS
  56.  *
  57.  *    Computes csubt (z1, z2) from:
  58.  *
  59.  *        1.    Let z1 = a + j b
  60.  *            Let z2 = c + j d
  61.  *
  62.  *        2.    Then csubt(z1,z2) = (a - c) + j (b - d)
  63.  *
  64.  */
  65.  
  66. #if !defined (__M68881__) && !defined (sfp004)
  67.  
  68. #include <stdio.h>
  69. #include <math.h>
  70. #include "pml.h"
  71.  
  72. COMPLEX csubt (z1, z2)
  73. COMPLEX z1;
  74. COMPLEX z2;
  75. {
  76.     z1.real -= z2.real;
  77.     z1.imag -= z2.imag;
  78.     return (z1);
  79. }
  80. #endif !defined (__M68881__) && !defined (sfp004)
  81.  
  82. #ifdef    __M68881__
  83. __asm("
  84. .text
  85. .even
  86. _funcname:
  87.     .ascii    \"csubt\\0\"
  88.     .even
  89.  
  90. .globl    _csubt
  91. _csubt:
  92.     fmoved    sp@(4),fp0
  93.     fsubd    sp@(20),fp0
  94.     fmoved    sp@(12),fp1
  95.     fsubd    sp@(28),fp1
  96.     movel    a1,d0        | pointer to result
  97.     fmoved    fp0,a1@        | return z.real
  98.     fmoved    fp1,a1@(8)    | return z.imag
  99. ");    /* end asm    */
  100. #endif    __M68881__
  101.  
  102. #ifdef    sfp004
  103. __asm("
  104.  
  105. comm =     -6
  106. resp =    -16
  107. zahl =      0
  108.  
  109. .even
  110. .text
  111. .even
  112. _funcname:
  113.     .ascii    \"csubt\\0\"
  114.     .even
  115. .text
  116. .even
  117. .globl    _csubt
  118. _csubt:
  119.     lea    0xfffa50,a0
  120.     movew    #0x5400,a0@(comm)    | z1.real -> fp0
  121.     .long    0x0c688900, 0xfff067f8
  122.     movel    a7@(4),a0@        | load arg_hi
  123.     movel    a7@(8),a0@        | load arg_low
  124.  
  125.     movew    #0x5428,a0@(comm)    | fp0 -= z2.real
  126.     .long    0x0c688900, 0xfff067f8
  127.     movel    a7@(20),a0@        | load arg_hi
  128.     movel    a7@(24),a0@        | load arg_low
  129.  
  130.     movew    #0x5480,a0@(comm)    | z1.imag -> fp1
  131.     .long    0x0c688900, 0xfff067f8
  132.     movel    a7@(12),a0@        | load arg_hi
  133.     movel    a7@(16),a0@        | load arg_low
  134.  
  135.     movew    #0x54a8,a0@(comm)    | fp1 -= z2.imag
  136.     movel    a1,d0            | pointer to result
  137.     .long    0x0c688900, 0xfff067f8
  138.     movel    a7@(28),a0@        | load arg_hi
  139.     movel    a7@(32),a0@        | load arg_low
  140.  
  141. |    movew    #%0111 0101 0000 0000,a0@(comm)    | fetch fp0
  142.     movew    #0x7400,a0@(comm)        | 
  143.     .long    0x0c688900, 0xfff067f8
  144.     movel    a0@(zahl),a1@
  145.     movel    a0@(zahl),a1@(4)
  146.  
  147. |    movew    #%0111 0100 1000 0000,a0@(comm)    | fetch fp1
  148.     movew    #0x7480,a0@(comm)        |
  149.     .long    0x0c688900, 0xfff067f8
  150.     movel    a0@(zahl),a1@(8)
  151.     movel    a0@(zahl),a1@(12)
  152. ");    /* end asm    */
  153. #endif    sfp004
  154.  
  155. #if defined (__M68881__) || defined (sfp004)
  156. # ifdef ERROR_CHECK    /* no error checking for now    */
  157.  
  158. __asm("    
  159.     pea    _funcname
  160.     jmp    c_err_check
  161. ");    /* end asm    */
  162.  
  163. # else  ERROR_CHECK
  164.  
  165. __asm("rts");
  166.  
  167. # endif ERROR_CHECK
  168. #endif defined (__M68881__) || defined (sfp004)
  169.